function initSearchPage() {
	$("a[name='topicItem']").bind("click", function(event, ui) {
		var contextPath = getContextPath();
		
		var selectedTopicLink = $(event.target);
		
		$.get(contextPath + "/getIntervalList", {topicId: selectedTopicLink.attr("data-topic-id")}, function(responseData) {
			var intervalList = $("#intervalPopup>ul[data-role='listview']");
			$("li:not(:first-child)", intervalList).remove();
			$.each(responseData.result, function(index, item) {
				var anIntervalContainer = $("<li />");
				
				var anInterval = $("<a />").attr("name", "intervalItem").attr("href", "#").attr("data-interval-id", item.intervalId).text(item.start + " to " + item.end);
				anInterval.bind("click", function(event, ui) {
					var selectedIntervalLink = $(this);
					var sentiment = selectedIntervalLink.find("img").attr("data-sentiment");
					
					$("#intervalId").val(selectedIntervalLink.attr("data-interval-id"));
					changeButtonText($("#openIntervalPopupButton"), selectedIntervalLink.text());
					$("<img />").attr("src", contextPath + "/images/sentiment_" + sentiment + ".png").attr("alt", "Sentiment: " + sentiment).addClass("sentimentThumbnail").prependTo($("#openIntervalPopupButton").children("span.ui-btn-inner").children("span.ui-btn-text"));
					$("#intervalPopup").popup("close");
					
					$("#searchButton").button("enable");
				});
				$("<img />").attr("src", contextPath + "/images/sentiment_" + item.sentiment + ".png").attr("alt", "Sentiment: " + item.sentiment).attr("data-sentiment", item.sentiment).addClass("ui-li-icon").appendTo(anInterval);
				anInterval.appendTo(anIntervalContainer);
				
				anIntervalContainer.appendTo(intervalList);
			});
			
			intervalList.listview("refresh");
			$("#openIntervalPopupButton").removeClass("ui-disabled");
			$("#intervalPopup").removeClass("hidden");
		});
		
		$("#topicId").val(selectedTopicLink.attr("data-topic-id"));
		changeButtonText($("#openTopicPopupButton"), selectedTopicLink.text());
		$("#topicPopup").popup("close");
	});
	
	$("#searchButton").bind("click", function(event, ui) {
		$("#searchForm").submit();
	});
	
	$("#resetButton").bind("click", function(event, ui) {
		$("#topicId").val("");
		changeButtonText($("#openTopicPopupButton"), "Select a Topic");
		
		$("#intervalId").val("");
		changeButtonText($("#openIntervalPopupButton"), "Select an Interval");
		var intervalList = $("#intervalPopup>ul[data-role='listview']");
		$("li:not(:first-child)", intervalList).remove();
		intervalList.listview("refresh");
		$("#openIntervalPopupButton").addClass("ui-disabled");
		$("#intervalPopup").addClass("hidden");
		
		$("#searchButton").button("disable");
	});
	
	$("#resetButton").trigger("click");
}
